<%@ page contentType="text/html" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Slevník | Slevový agregátor</title>
        <link type="text/css" rel="stylesheet" media="all" href="${pageContext.request.contextPath}/css/styles.css" />
        <link type="text/css" rel="stylesheet" media="print" href="${pageContext.request.contextPath}/css/print.css" />
    </head>
    <body>

        <div id="clouds"></div>

        <div id="page">

            <div id="header-wrapper">
                <div id="header">
                    <a href="${pageContext.request.contextPath}/" title="Slevník">
                        <div id="logo">
                            <div>Slevník - Království plné slev</div>
                        </div>
                    </a>
                </div>
                <div class="clear"></div>
            </div>

            <div id="main-wrapper">
                <div id="main">
                    <c:if test="${not empty error}">
                        <div id="messages">
                            Error: <c:out value="${error}"/>
                        </div>
                    </c:if>
                    <div id="content">
                        <div class="content">
                            <h1>Aktuální nabídka (<c:out value="${itemsCount}"/> slev)</h1>
                            <c:forEach items="${items}" var="item" begin="${page * 10}" end="${page * 10 + 9}">
                                <div class="item">
                                    <h2><a href="${item.url}"><span class="city"><c:out value="${item.city}"/></span>:
                                            <c:out value="${item.title}"/></a></h2>
                                    <div class="details">
                                        <div class="part">
                                            <div class="bold">Sleva: <span><fmt:formatNumber value="${item.discount}"/> %</span></div>
                                        </div>
                                        <div class="part">
                                            <div class="bold">Cena: <span><fmt:formatNumber value="${item.finalPrice}"/> Kč</span></div>
                                            <div>Původně: <fmt:formatNumber value="${item.originalPrice}"/> Kč</div>
                                        </div>
                                        <div class="part">
                                            <div class="bold">Platí do: <span><c:out value="${item.dealEnd}"/></span></div>
                                            <div>Zakoupeno: <c:out value="${item.customers}"/> x</div>
                                        </div>
                                    </div>
                                    <div class="clear"></div>
                                </div>
                            </c:forEach>
                            <div id="pager">
                                <c:forEach begin="1" end="${page}" varStatus="status">
                                    <a href="${pageContext.request.contextPath}/?city=${param.city}&category=${param.category}&sort=${param.sort}&asc=${param.asc}&find=${param.find}&nearest=${param.nearest}&page=${status.count - 1}"><span><c:out value="${status.count}"/></span></a> -
                                </c:forEach>
                                <b><span><c:out value="${page + 1}"/></span></b>
                                <c:forEach begin="${page + 2}" end="${pagesCount + 1}" varStatus="status">
                                    - <a href="${pageContext.request.contextPath}/?city=${param.city}&category=${param.category}&sort=${param.sort}&asc=${param.asc}&find=${param.find}&nearest=${param.nearest}&page=${page + status.count}"><span><c:out value="${page + status.count + 1}"/></span></a>
                                </c:forEach>
                            </div>
                        </div>
                    </div>
                    <div id="sidebar">
                        <div class="content">
                            <h2>Vyhledávání:</h2>
                            <form method="POST" action="${pageContext.request.contextPath}/">
                                <input type="text" name="find" value="${param.find}" />
                                <input type="submit" name="" value="Hledat" />
                            </form>
                            <h2>Města:</h2>
                            <ul>
                                <li<c:if test="${empty param.city}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=&category=${param.category}&sort=${param.sort}&asc=${param.asc}">Celá ČR</a></li>
                                <li<c:if test="${param.city eq 'Praha'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=Praha&category=${param.category}&sort=${param.sort}&asc=${param.asc}">Praha</a></li>
                                <li<c:if test="${param.city eq 'Brno'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=Brno&category=${param.category}&sort=${param.sort}&asc=${param.asc}">Brno</a></li>
                                <li<c:if test="${param.city eq 'České Budějovice'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=České Budějovice&category=${param.category}&sort=${param.sort}&asc=${param.asc}">České Budějovice</a></li>
                                <li<c:if test="${param.city eq 'Hradec Králové'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=Hradec Králové&category=${param.category}&sort=${param.sort}&asc=${param.asc}">Hradec Králové</a></li>
                                <li<c:if test="${param.city eq 'Karlovy Vary'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=Karlovy Vary&category=${param.category}&sort=${param.sort}&asc=${param.asc}">Karlovy Vary</a></li>
                                <li<c:if test="${param.city eq 'Liberec'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=Liberec&category=${param.category}&sort=${param.sort}&asc=${param.asc}">Liberec</a></li>
                                <li<c:if test="${param.city eq 'Olomouc'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=Olomouc&category=${param.category}&sort=${param.sort}&asc=${param.asc}">Olomouc</a></li>
                                <li<c:if test="${param.city eq 'Ostrava'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=Ostrava&category=${param.category}&sort=${param.sort}&asc=${param.asc}">Ostrava</a></li>
                                <li<c:if test="${param.city eq 'Pardubice'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=Pardubice&category=${param.category}&sort=${param.sort}&asc=${param.asc}">Pardubice</a></li>
                                <li<c:if test="${param.city eq 'Plzeň'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=Plzeň&category=${param.category}&sort=${param.sort}&asc=${param.asc}">Plzeň</a></li>
                                <li<c:if test="${param.city eq 'Ústí nad Labem'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=Ústí nad Labem&category=${param.category}&sort=${param.sort}&asc=${param.asc}">Ústí nad Labem</a></li>
                            </ul>
                            <h2>Seřadit podle vzdálenosti k městu:</h2>
                            <form method="POST" action="${pageContext.request.contextPath}/">
                                <input type="text" name="nearest" value="${param.nearest}" />
                                <input type="submit" name="" value="Seřadit" />
                            </form>
                            <h2>Kategorie:</h2>
                            <ul>
                                <li<c:if test="${empty param.category}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=${param.city}&category=&sort=${param.sort}&asc=${param.asc}">Všechny</a></li>
                                <c:forEach items="${categories}" var="category">
                                    <li<c:if test="${param.category eq category.id}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=${param.city}&category=${category.id}&sort=${param.sort}&asc=${param.asc}"><c:out value="${category.name}"/></a></li>
                                </c:forEach>
                            </ul>
                            <h2>Řazení:</h2>
                            <ul>
                                <li>Cena:</li>
                                <ul>
                                    <li<c:if test="${param.sort eq 'price' and param.asc eq 'true'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=${param.city}&category=${param.category}&sort=price&asc=true">Od nejlevnější</a></li>
                                    <li<c:if test="${param.sort eq 'price' and param.asc eq 'false'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=${param.city}&category=${param.category}&sort=price&asc=false">Od nejdražší</a></li>
                                </ul>
                                <li>Čas na nákup:</li>
                                <ul>
                                    <li<c:if test="${param.sort eq 'time' and param.asc eq 'false'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=${param.city}&category=${param.category}&sort=time&asc=false">Od nejdelšího</a></li>
                                    <li<c:if test="${param.sort eq 'time' and param.asc eq 'true'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=${param.city}&category=${param.category}&sort=time&asc=true">Od nekratšího</a></li>
                                </ul>
                                <li>Prodávanost:</li>
                                <ul>
                                    <li<c:if test="${param.sort eq 'customers' and param.asc eq 'false'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=${param.city}&category=${param.category}&sort=customers&asc=false">Od nejvyšší</a></li>
                                    <li<c:if test="${param.sort eq 'customers' and param.asc eq 'true'}"> class="active"</c:if>><a href="${pageContext.request.contextPath}/?city=${param.city}&category=${param.category}&sort=customers&asc=true">Od nejnižší</a></li>
                                </ul>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>

            <div id="footer-wrapper">
                <div id="footer">
                    <p>Copyright © 2011</p>
                </div>
                <div class="clear"></div>
            </div>

            <div id="bottom"></div>

        </div>

    </body>
</html>
